Try to make sure that we have some focused widget on map. (#50339)
authorOwen Taylor <otaylor@redhat.com>
Wed, 30 Jan 2002 18:58:31 +0000 (18:58 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 30 Jan 2002 18:58:31 +0000 (18:58 +0000)
Wed Jan 30 13:55:59 2002  Owen Taylor  <otaylor@redhat.com>

* gtk/gtkwindow.c (gtk_window_show): Try to make
sure that we have some focused widget on map. (#50339)

* gtk/gtkdialog.c (gtk_dialog_map): Handling picking
a focus widget here differently so that if a
response button gets picked, it's the default one.

* tests/testgtk.c (make_message_dialog): Set the
default response for the dialogs.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkdialog.c
gtk/gtkwindow.c

index c6d2928d3bf42472164ca74e71928c9b028cefb7..5eca98d4ac7d86888af80c358406505c8a7ddf4e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,18 @@
+Wed Jan 30 13:55:59 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwindow.c (gtk_window_show): Try to make
+       sure that we have some focused widget on map. (#50339)
+
+       * gtk/gtkdialog.c (gtk_dialog_map): Handling picking
+       a focus widget here differently so that if a
+       response button gets picked, it's the default one.
+
+       * tests/testgtk.c (make_message_dialog): Set the 
+       default response for the dialogs.
+
 Tue Jan 29 22:52:36 2002  Owen Taylor  <otaylor@redhat.com>
 
-       * 1.3.13
+       * Released 1.3.13
 
        * configure.in: Micro version 13, interface, binary
        age 0. Require GLIB-1.3.13, Pango 0.24.
index c6d2928d3bf42472164ca74e71928c9b028cefb7..5eca98d4ac7d86888af80c358406505c8a7ddf4e 100644 (file)
@@ -1,6 +1,18 @@
+Wed Jan 30 13:55:59 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwindow.c (gtk_window_show): Try to make
+       sure that we have some focused widget on map. (#50339)
+
+       * gtk/gtkdialog.c (gtk_dialog_map): Handling picking
+       a focus widget here differently so that if a
+       response button gets picked, it's the default one.
+
+       * tests/testgtk.c (make_message_dialog): Set the 
+       default response for the dialogs.
+
 Tue Jan 29 22:52:36 2002  Owen Taylor  <otaylor@redhat.com>
 
-       * 1.3.13
+       * Released 1.3.13
 
        * configure.in: Micro version 13, interface, binary
        age 0. Require GLIB-1.3.13, Pango 0.24.
index c6d2928d3bf42472164ca74e71928c9b028cefb7..5eca98d4ac7d86888af80c358406505c8a7ddf4e 100644 (file)
@@ -1,6 +1,18 @@
+Wed Jan 30 13:55:59 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwindow.c (gtk_window_show): Try to make
+       sure that we have some focused widget on map. (#50339)
+
+       * gtk/gtkdialog.c (gtk_dialog_map): Handling picking
+       a focus widget here differently so that if a
+       response button gets picked, it's the default one.
+
+       * tests/testgtk.c (make_message_dialog): Set the 
+       default response for the dialogs.
+
 Tue Jan 29 22:52:36 2002  Owen Taylor  <otaylor@redhat.com>
 
-       * 1.3.13
+       * Released 1.3.13
 
        * configure.in: Micro version 13, interface, binary
        age 0. Require GLIB-1.3.13, Pango 0.24.
index c6d2928d3bf42472164ca74e71928c9b028cefb7..5eca98d4ac7d86888af80c358406505c8a7ddf4e 100644 (file)
@@ -1,6 +1,18 @@
+Wed Jan 30 13:55:59 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwindow.c (gtk_window_show): Try to make
+       sure that we have some focused widget on map. (#50339)
+
+       * gtk/gtkdialog.c (gtk_dialog_map): Handling picking
+       a focus widget here differently so that if a
+       response button gets picked, it's the default one.
+
+       * tests/testgtk.c (make_message_dialog): Set the 
+       default response for the dialogs.
+
 Tue Jan 29 22:52:36 2002  Owen Taylor  <otaylor@redhat.com>
 
-       * 1.3.13
+       * Released 1.3.13
 
        * configure.in: Micro version 13, interface, binary
        age 0. Require GLIB-1.3.13, Pango 0.24.
index c6d2928d3bf42472164ca74e71928c9b028cefb7..5eca98d4ac7d86888af80c358406505c8a7ddf4e 100644 (file)
@@ -1,6 +1,18 @@
+Wed Jan 30 13:55:59 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwindow.c (gtk_window_show): Try to make
+       sure that we have some focused widget on map. (#50339)
+
+       * gtk/gtkdialog.c (gtk_dialog_map): Handling picking
+       a focus widget here differently so that if a
+       response button gets picked, it's the default one.
+
+       * tests/testgtk.c (make_message_dialog): Set the 
+       default response for the dialogs.
+
 Tue Jan 29 22:52:36 2002  Owen Taylor  <otaylor@redhat.com>
 
-       * 1.3.13
+       * Released 1.3.13
 
        * configure.in: Micro version 13, interface, binary
        age 0. Require GLIB-1.3.13, Pango 0.24.
index c6d2928d3bf42472164ca74e71928c9b028cefb7..5eca98d4ac7d86888af80c358406505c8a7ddf4e 100644 (file)
@@ -1,6 +1,18 @@
+Wed Jan 30 13:55:59 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwindow.c (gtk_window_show): Try to make
+       sure that we have some focused widget on map. (#50339)
+
+       * gtk/gtkdialog.c (gtk_dialog_map): Handling picking
+       a focus widget here differently so that if a
+       response button gets picked, it's the default one.
+
+       * tests/testgtk.c (make_message_dialog): Set the 
+       default response for the dialogs.
+
 Tue Jan 29 22:52:36 2002  Owen Taylor  <otaylor@redhat.com>
 
-       * 1.3.13
+       * Released 1.3.13
 
        * configure.in: Micro version 13, interface, binary
        age 0. Require GLIB-1.3.13, Pango 0.24.
index c6d2928d3bf42472164ca74e71928c9b028cefb7..5eca98d4ac7d86888af80c358406505c8a7ddf4e 100644 (file)
@@ -1,6 +1,18 @@
+Wed Jan 30 13:55:59 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkwindow.c (gtk_window_show): Try to make
+       sure that we have some focused widget on map. (#50339)
+
+       * gtk/gtkdialog.c (gtk_dialog_map): Handling picking
+       a focus widget here differently so that if a
+       response button gets picked, it's the default one.
+
+       * tests/testgtk.c (make_message_dialog): Set the 
+       default response for the dialogs.
+
 Tue Jan 29 22:52:36 2002  Owen Taylor  <otaylor@redhat.com>
 
-       * 1.3.13
+       * Released 1.3.13
 
        * configure.in: Micro version 13, interface, binary
        age 0. Require GLIB-1.3.13, Pango 0.24.
index dec95d52450aca2fbfdabe0b5462f43492d2c25a..db87ce5b8c054ddef70ae6dd53a8221435c620c7 100644 (file)
@@ -57,6 +57,7 @@ static void gtk_dialog_get_property      (GObject          *object,
                                           GParamSpec       *pspec);
 static void gtk_dialog_style_set         (GtkWidget        *widget,
                                           GtkStyle         *prev_style);
+static void gtk_dialog_map               (GtkWidget        *widget);
 
 static void gtk_dialog_close             (GtkDialog        *dialog);
 
@@ -116,6 +117,7 @@ gtk_dialog_class_init (GtkDialogClass *class)
   gobject_class->set_property = gtk_dialog_set_property;
   gobject_class->get_property = gtk_dialog_get_property;
   
+  widget_class->map = gtk_dialog_map;
   widget_class->style_set = gtk_dialog_style_set;
 
   class->close = gtk_dialog_close;
@@ -296,6 +298,45 @@ gtk_dialog_delete_event_handler (GtkWidget   *widget,
   return FALSE;
 }
 
+/* A far too tricky heuristic for getting the right initial
+ * focus widget if none was set. What we do is we focus the first
+ * widget in the tab chain, but if this results in the focus
+ * ending up on one of the response widgets _other_ than the
+ * default response, we focus the default response instead.
+ */
+static void
+gtk_dialog_map (GtkWidget *widget)
+{
+  GtkWindow *window = GTK_WINDOW (widget);
+  GtkDialog *dialog = GTK_DIALOG (widget);
+  
+  GTK_WIDGET_CLASS (parent_class)->map (widget);
+
+  if (!window->focus_widget)
+    {
+      GList *children, *tmp_list;
+      
+      g_signal_emit_by_name (window, "move_focus", GTK_DIR_TAB_FORWARD);
+
+      tmp_list = children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
+
+      while (tmp_list)
+       {
+         GtkWidget *child = tmp_list->data;
+
+         if (child == window->focus_widget && child != window->default_widget && window->default_widget)
+           {
+             gtk_widget_grab_focus (window->default_widget);
+             break;
+           }
+         
+         tmp_list = tmp_list->next;
+       }
+
+      g_list_free (children);
+    }
+}
+
 static void
 gtk_dialog_style_set (GtkWidget *widget,
                       GtkStyle  *prev_style)
index 8271db1474d9ab0cc39b1a9d617c2a6762e171d6..79df74744ce5bae4a5ba183d9dd9f74d2837d8aa 100644 (file)
@@ -2980,12 +2980,12 @@ gtk_window_show (GtkWidget *widget)
   GtkWindow *window = GTK_WINDOW (widget);
   GtkContainer *container = GTK_CONTAINER (window);
   gboolean need_resize;
-  
+
   GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
   
   need_resize = container->need_resize || !GTK_WIDGET_REALIZED (widget);
   container->need_resize = FALSE;
-  
+
   if (need_resize)
     {
       GtkWindowGeometryInfo *info = gtk_window_get_geometry_info (window, TRUE);
@@ -3046,6 +3046,11 @@ gtk_window_show (GtkWidget *widget)
 
   gtk_widget_map (widget);
 
+  /* Try to make sure that we have some focused widget
+   */
+  if (!window->focus_widget)
+    gtk_window_move_focus (window, GTK_DIR_TAB_FORWARD);
+  
   if (window->modal)
     gtk_grab_add (widget);
 }